package md.lanjing.com.module_wallet.contact;

import android.content.Context;


import com.lxh.baselibray.mvp.BasePresent;
import com.lxh.baselibray.mvp.IBaseView;
import com.lxh.baselibray.net.NetCallBack;
import com.lxh.baselibray.net.ServiceGenerator;
import com.lxh.baselibray.util.SPUtils;
import com.lxh.baselibray.util.ToastUtils;



import com.lxh.baselibray.constant.Constant;


import md.lanjing.com.module_wallet.api.WalletApiService;
import md.lanjing.com.module_wallet.bean.DealCenterNacVacancyResponce;
import md.lanjing.com.module_wallet.bean.QueryIncomeResponce;
import retrofit2.Call;
import retrofit2.Response;

public class MyWalletContact {
    public static class MyWalletPresent extends BasePresent<IMyWalletView> {
        public void getVacancy(final Context context){
            WalletApiService service= ServiceGenerator.createService(WalletApiService.class);
            int userId= SPUtils.getInt(Constant.USER_ID,-1,context);
            service.getNacVaCancy(userId).enqueue(new NetCallBack<DealCenterNacVacancyResponce>() {
                @Override
                public void onSuccess(Call<DealCenterNacVacancyResponce> call, Response<DealCenterNacVacancyResponce> response) {
                    if (getView()!=null){
                        getView().getVacancyData(response);
                    }

                }

                @Override
                public void onFailed() {
                    ToastUtils.showLongToast(context,"网络请求异常");
                }
            });

        }

        public void queryIncome(final Context context){
            WalletApiService service= ServiceGenerator.createService(WalletApiService.class);
            int userId= SPUtils.getInt(Constant.USER_ID,-1,context);
            service.getPerProfit(userId).enqueue(new NetCallBack<QueryIncomeResponce>() {
                @Override
                public void onSuccess(Call<QueryIncomeResponce> call, Response<QueryIncomeResponce> response) {
                    if (getView()!=null){
                        getView().getQueryIncomeData(response);
                    }
                }

                @Override
                public void onFailed() {
                    ToastUtils.showLongToast(context,"网络请求异常");
                }
            });

        }
    }
    public interface IMyWalletView extends IBaseView {
        void getVacancyData(Response<DealCenterNacVacancyResponce> response);
        void getQueryIncomeData(Response<QueryIncomeResponce> response);
    }
}
